<!DOCTYPE html>
<html lang=''>

<head>
  <meta charset='UTF-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>Document</title>
  <script src='./vue.js'></script>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      background-color: beige;
    }

    .nav {
      height: 44px;
      width: 100%;
      background-color: white;
      border-bottom: 1px solid gainsboro;
      position: relative;
    }

    .nav h4 {
      width: calc(100% - 140px);
      line-height: 44px;
      margin: 0 auto;
      text-align: center;
    }

    .back {
      position: absolute;
      left: 10px;
      top: 0;
      line-height: 44px;
    }

    .right {
      position: absolute;
      right: 10px;
      top: 0;
      line-height: 44px;
    }
  </style>
</head>

<body>
  <div id='app'>
    <navcom title="首页"> </navcom>

    <navcom title="详情">
      <span class="back">返回</span>
    </navcom>


    <navcom title="其他">
      <span class="back">返回</span>
      <span class="right"> 搜索 </span>
    </navcom>

  </div>
</body>

<!-- 导航条组件模板 -->
<template id="nav">
  <div class="nav">
    <slot></slot>
    <h4>{{title}}</h4>
    <!-- <slot></slot> -->
  </div>
</template>

<script>
  const app = Vue.createApp({
    data () {
      return {

      }
    },
  })

  app.component('navcom', {
    template: '#nav',
    props: ['title']
  })


  app.mount('#app')
</script>

</html>
